Buttons are found in electronic devices, each button of the electronic device is coupled to a general purpose input output (GPIO) port of a component (e.g., a processor) of the electronic device. Thus, the electronic device can determine whether the button is pressed according to a pulse signal output from the GPIO.